#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    string kthDistinct(vector<string>& arr, int k) {
        map<string, int> m1;
        for (auto& e : arr)
        {
            m1[e]++;
        }
        auto it = arr.begin();
        while (it != arr.end())
        {
            if (m1[*it] > 1)
            {
                it = arr.erase(it);
                continue;
            }
            ++it;
        }
        if (arr.size() < k)
            return "";
        else
            return arr[k - 1];
    }
};